package com.roy.shortlink.admin.common.convention.exception;

import com.roy.shortlink.admin.common.convention.errorcode.BaseErrorCode;
import com.roy.shortlink.admin.common.convention.errorcode.IErrorCode;

/**
 * 客户端异常
 */
public class ClientException extends AbstractException {

    // 将枚举类放进来，直接可以输出，异常码，异常信息
    public ClientException(IErrorCode errorCode) {
        this(null, null, errorCode);
    }

    // 不用异常码的方式，直接返回错误信息
    public ClientException(String message) {
        this(message, null, BaseErrorCode.CLIENT_ERROR);
    }

    // 想用异常码，但是想自己写异常信息，用这个
    public ClientException(String message, IErrorCode errorCode) {
        this(message, null, errorCode);
    }

    public ClientException(String message, Throwable throwable, IErrorCode errorCode) {
        super(message, throwable, errorCode);
    }

    @Override
    public String toString() {
        return "ClientException{" +
                "code='" + errorCode + "'," +
                "message='" + errorMessage + "'" +
                '}';
    }
}
